<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>备份与恢复 - 家庭药品管理</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/common.css">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#16a34a',
                        secondary: '#4ade80',
                        dark: '#1e293b',
                        light: '#f8fafc'
                    }
                }
            }
        }
    </script>
    <style>
        /* iPhone 15 模拟外壳样式 */
        .iphone-frame {
            width: 390px;
            height: 844px;
            border-radius: 44px;
            background-color: #000;
            margin: 20px auto;
            position: relative;
            overflow: hidden;
            box-shadow: 0 0 0 10px #111, 0 0 0 11px #333, 0 20px 50px rgba(0, 0, 0, 0.3);
        }
        
        /* 顶部刘海区域 */
        .iphone-notch {
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 200px;
            height: 30px;
            background-color: #000;
            border-radius: 0 0 20px 20px;
            z-index: 10;
        }
        
        /* 底部安全区域 */
        .iphone-home-indicator {
            position: absolute;
            bottom: 8px;
            left: 50%;
            transform: translateX(-50%);
            width: 120px;
            height: 5px;
            background-color: rgba(255, 255, 255, 0.6);
            border-radius: 5px;
            z-index: 10;
        }
        
        /* 顶部状态栏 */
        .iphone-status-bar {
            height: 50px;
            background-color: #fff;
            padding-top: 15px;
            padding-left: 20px;
            padding-right: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 14px;
            font-weight: 600;
        }
        
        /* 内容区域 */
        .iphone-content {
            height: calc(100% - 50px - 83px);
            background-color: #f8fafc;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding: 20px;
        }
        
        /* 底部导航栏 */
        .iphone-nav {
            height: 83px;
            background-color: white;
            border-top: 1px solid #e5e7eb;
            display: flex;
            justify-content: space-around;
            align-items: center;
            position: absolute;
            bottom: 0;
            width: 100%;
        }
        
        /* 导航项样式 */
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #9ca3af;
            text-decoration: none;
            font-size: 12px;
        }
        
        .nav-item.active {
            color: #16a34a;
        }
        
        .nav-item i {
            font-size: 22px;
            margin-bottom: 5px;
        }
        
        /* 页面头部样式 */
        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .page-header h1 {
            font-size: 18px;
            font-weight: 600;
            color: #1e293b;
        }
        
        /* 卡片样式 */
        .card {
            background-color: white;
            border-radius: 12px;
            margin-bottom: 16px;
            overflow: hidden;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }
        
        .card-header {
            padding: 16px 20px;
            border-bottom: 1px solid #f1f5f9;
        }
        
        .card-title {
            font-size: 16px;
            font-weight: 600;
            color: #1e293b;
        }
        
        .card-body {
            padding: 20px;
        }
        
        /* 操作按钮样式 */
        .action-button {
            width: 100%;
            padding: 14px;
            border-radius: 12px;
            font-weight: 600;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 8px;
            margin-bottom: 12px;
            border: none;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .action-button:active {
            transform: scale(0.98);
        }
        
        /* 备份项目样式 */
        .backup-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px;
            border-bottom: 1px solid #f1f5f9;
        }
        
        .backup-item:last-child {
            border-bottom: none;
        }
        
        .backup-info {
            flex: 1;
        }
        
        .backup-date {
            font-weight: 500;
            color: #1e293b;
            margin-bottom: 4px;
        }
        
        .backup-details {
            font-size: 14px;
            color: #64748b;
        }
        
        .backup-actions {
            display: flex;
            gap: 8px;
        }
        
        .action-icon {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #64748b;
            background-color: #f1f5f9;
            cursor: pointer;
        }
        
        .info-text {
            padding: 16px;
            background-color: #eff6ff;
            border-radius: 8px;
            border-left: 4px solid #3b82f6;
            font-size: 14px;
            color: #374151;
            margin-bottom: 16px;
        }
        
        .info-text i {
            margin-right: 8px;
            color: #3b82f6;
        }
    </style>
</head>
<body>
    <div class="iphone-frame">
        <!-- 顶部刘海 -->
        <div class="iphone-notch"></div>
        
        <!-- 状态栏 -->
        <div class="iphone-status-bar">
            <div>9:41</div>
            <div class="flex space-x-2">
                <i class="fa fa-signal"></i>
                <i class="fa fa-wifi"></i>
                <i class="fa fa-battery-full"></i>
            </div>
        </div>
        
        <!-- 内容区域 -->
        <div class="iphone-content">
            <!-- 顶部导航 -->
            <div class="page-header">
                <div class="flex items-center">
                    <button class="mr-4 w-8 h-8 flex items-center justify-center" id="backButton">
                        <i class="fa fa-arrow-left text-gray-600"></i>
                    </button>
                    <h1>备份与恢复</h1>
                </div>
            </div>

            <!-- 备份提示信息 -->
            <div class="info-text">
                <i class="fa fa-info-circle"></i>
                定期备份您的数据可以防止意外情况下的数据丢失。所有备份数据均存储在您的设备上。
            </div>

            <!-- 备份选项卡片 -->
            <div class="card mb-6">
                <div class="card-header">
                    <div class="card-title">备份选项</div>
                </div>
                <div class="card-body">
                    <button class="action-button bg-primary text-white mb-4">
                        <i class="fa fa-download"></i>
                        <span>创建备份</span>
                    </button>
                    
                    <div class="space-y-2 text-sm">
                        <div class="flex items-center">
                            <input type="checkbox" id="backupMedicines" class="mr-2" checked>
                            <label for="backupMedicines">备份药品信息</label>
                        </div>
                        <div class="flex items-center">
                            <input type="checkbox" id="backupReminders" class="mr-2" checked>
                            <label for="backupReminders">备份用药提醒</label>
                        </div>
                        <div class="flex items-center">
                            <input type="checkbox" id="backupRecords" class="mr-2" checked>
                            <label for="backupRecords">备份用药记录</label>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 恢复选项卡片 -->
            <div class="card mb-6">
                <div class="card-header">
                    <div class="card-title">恢复选项</div>
                </div>
                <div class="card-body">
                    <button class="action-button bg-gray-100 text-gray-800 mb-4">
                        <i class="fa fa-upload"></i>
                        <span>从文件恢复</span>
                    </button>
                    <p class="text-sm text-gray-600 mb-4">选择一个之前导出的备份文件(.medb)进行恢复</p>
                </div>
            </div>

            <!-- 最近备份记录 -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title">最近备份</div>
                </div>
                
                <!-- 备份项目 -->
                <div class="backup-item">
                    <div class="backup-info">
                        <div class="backup-date">2023-09-15 14:30</div>
                        <div class="backup-details">包含24种药品、12个提醒</div>
                    </div>
                    <div class="backup-actions">
                        <div class="action-icon" title="恢复">
                            <i class="fa fa-refresh"></i>
                        </div>
                        <div class="action-icon" title="删除">
                            <i class="fa fa-trash"></i>
                        </div>
                    </div>
                </div>
                
                <div class="backup-item">
                    <div class="backup-info">
                        <div class="backup-date">2023-09-01 09:15</div>
                        <div class="backup-details">包含22种药品、10个提醒</div>
                    </div>
                    <div class="backup-actions">
                        <div class="action-icon" title="恢复">
                            <i class="fa fa-refresh"></i>
                        </div>
                        <div class="action-icon" title="删除">
                            <i class="fa fa-trash"></i>
                        </div>
                    </div>
                </div>
                
                <div class="backup-item">
                    <div class="backup-info">
                        <div class="backup-date">2023-08-15 18:45</div>
                        <div class="backup-details">包含20种药品、8个提醒</div>
                    </div>
                    <div class="backup-actions">
                        <div class="action-icon" title="恢复">
                            <i class="fa fa-refresh"></i>
                        </div>
                        <div class="action-icon" title="删除">
                            <i class="fa fa-trash"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 底部导航栏 -->
        <div class="iphone-nav">
            <a href="index.html" class="nav-item">
                <i class="fa fa-home"></i>
                <span>首页</span>
            </a>
            <a href="medicine_management.html" class="nav-item">
                <i class="fa fa-medkit"></i>
                <span>药品</span>
            </a>
            <a href="add_medicine.html" class="nav-item">
                <i class="fa fa-plus"></i>
                <span>添加</span>
            </a>
            <a href="reminder.html" class="nav-item">
                <i class="fa fa-bell"></i>
                <span>提醒</span>
            </a>
            <a href="profile.html" class="nav-item active">
                <i class="fa fa-user"></i>
                <span>我的</span>
            </a>
        </div>
        
        <!-- 底部安全指示器 -->
        <div class="iphone-home-indicator"></div>
    </div>

    <script>
        // 返回按钮点击事件
        document.getElementById('backButton').addEventListener('click', function() {
            window.history.back();
        });

        // 创建备份按钮点击事件
        document.querySelector('.bg-primary.action-button').addEventListener('click', function() {
            // 在实际应用中，这里可以执行创建备份的逻辑
            console.log('用户点击了创建备份');
            alert('备份创建成功！');
        });

        // 从文件恢复按钮点击事件
        document.querySelector('.bg-gray-100.action-button').addEventListener('click', function() {
            // 在实际应用中，这里可以打开文件选择对话框
            console.log('用户点击了从文件恢复');
            // 这里仅作演示，实际应用中需要使用File API
            alert('请选择备份文件(.medb)进行恢复');
        });

        // 备份操作按钮点击事件
        const restoreButtons = document.querySelectorAll('.action-icon .fa-refresh');
        restoreButtons.forEach((button, index) => {
            button.parentElement.addEventListener('click', function() {
                console.log('用户点击了恢复备份 ' + (index + 1));
                if (confirm('确定要从该备份恢复数据吗？这将覆盖当前所有数据。')) {
                    alert('数据恢复成功！');
                }
            });
        });

        // 删除备份按钮点击事件
        const deleteButtons = document.querySelectorAll('.action-icon .fa-trash');
        deleteButtons.forEach((button, index) => {
            button.parentElement.addEventListener('click', function() {
                console.log('用户点击了删除备份 ' + (index + 1));
                if (confirm('确定要删除该备份吗？此操作不可恢复。')) {
                    alert('备份已删除！');
                }
            });
        });
    </script>
</body>
</html>